<script type="text/javascript">
<!--
$(document).ready(function(){
							$('.tuan').hide();
							});
$('.plus').live('click',function(){
							$id =$(this).attr('id');
							root=$('#root').val();
							sotuan = $('#sotuan'+$id).val();
							jQuery(this).attr('src',root+'img/minus.png');
							for (i=1;i<=7;i++)
							{
								$('#tuan'+$id+$i).show(1000);
							}
							$(this).addClass('minus');
							$(this).attr('class','minus');
							});
$('.minus').live('click',function(){
							$id =$(this).attr('id');
							root=$('#root').val();
							sotuan = $('#sotuan'+$id).val();
							jQuery(this).attr('src',root+'img/plus.png');
							if(!isNaN(sotuan)){}
							else
								sotuan = 7;
							for (i=1;i<=sotuan;i++)
							{
								$('#tuan'+$id+$i).hide(1000);
							}
							$(this).attr('class','plus');
							});

//-->
</script>
<?php echo $form->create('Kehoaches');?>
<?php
echo $form->input('root',array('id'=>'root','type'=>'hidden','value'=>$this->webroot));
	if(empty($nams))
		$nams =array(); 
 echo $form->input('nam',array('id'=>'nam','label'=>'Năm','options'=>$nams,'empty'=>"Chọn Năm",'selected'=>date('Y')));?>
<div class="kehoaches">
	<h2><?php __('Chọn thời gian để xem chỉ tiêu được giao');?></h2>
<div id='tbltg'>
	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Thời gian';?></th>
			<th class="actions"><?php __('Lựa chọn');?></th>
			<th class="status"><?php __('Trạng Thái');?></th>
	</tr>
	<?php
	$i = 0;$sttthang=0;$stttuan=0;
	foreach ($kehoachthangs as $kehoachthang):
	$thanght = date('m',strtotime($kehoachthang['Thoigian']['ngaykt']));
		$class = null;
		$id=null;
		$align =null;
		$khcngay =date('d-m-Y',strtotime($kehoachthang['Thoigian']['ngaykt']))-date('d-m-Y',strtotime($kehoachthang['Thoigian']['ngaybd']));
			if ($sttthang>0)
				echo $form->input('', array('type'=>'hidden','value'=>$stttuan,'id'=>'sotuan'.$sttthang));
			$sttthang++;
			$id = ' id ='.$sttthang;
	?>
	<tr<?php echo $class.$id;?>>
		<td ><?php
					echo $sttthang;
		 ?>&nbsp;</td>
		<td <?php echo $align?>>
			<?php
			echo $html->image('/img/plus.png', array('class'=>'plus','id'=>$sttthang)); 
			echo '<strong>'.$kehoachthang['Thoigian']['thoigian'].'</strong>'; ?>
		</td>
       
        
		<td class="actions">
			<?php echo $this->Html->link(__('Chỉ tiêu tháng', true), array('controller'=>'chitieunvs','action' => 'hienctgiaothangnv', $kehoachthang['Kehoach']['id']));?>
                    
		</td>
		<td class="status" align='center'>
			<?php 
                      	if ($kehoachthang['Kehoach']['dagiao']==1)
                      	{
                      		echo $form->label('','Trung Tâm Đã Giao');
                      	}
                      	else
                      	{
                      		echo $form->label('','Trung Tâm Chưa Giao');                      		
                      	}
             ?>
                   
                    
		</td>
	</tr>
	<?php
			$stttuan=0; 
	foreach ($kehoachtuans as $kehoachtuan):
			$thangoftuan = date('m',strtotime($kehoachtuan['Thoigian']['ngaykt']));
		if($thanght==$thangoftuan)
		{
			$class = null;
			$id=null;
			$align =null;
			$stttuan++;
			$class = ' class = tuan ';
			$id = ' id =tuan'.$sttthang.$stttuan;
			$align = ' align=right';
	?>
	<tr<?php echo $class.$id;?>>
		<td ><?php
		 ?>&nbsp;</td>
		<td <?php echo $align?>>
			<?php echo $kehoachtuan['Thoigian']['thoigian']; ?>
		</td>
       
        
		<td class="actions">
			<?php 
                      echo $this->Html->link(__('Chỉ tiêu Tuần', true), array('controller'=>'chitieunvs','action' => 'hienchitieu', $kehoachthang['Kehoach']['id']));
                    ?>
		</td>
		<td class="status">
			<?php
                        if ($kehoachtuan['Kehoach']['dagiao']==1)
                      	{
                      		echo $form->label('','Trung Tâm Đã Giao');
                      	}
                      	else
                      	{
                      		echo $form->label('','Trung Tâm Chưa Giao');                      		
                      	}
                    ?>
		</td>
		
		
	</tr>
	<?php }
		endforeach; 
endforeach; ?>
	</table>
	</div>
</div>
<?php
$this->Js->get('#nam')->event('change',
								$this->Js->request(array('controller' => 'kehoaches', 'action' => 'laytheodoict'),
								array('update' => '#tbltg','async' => true,
								'dataExpression' => true,'method' => 'post',
								'data' => $js->serializeForm(array('isForm' => true, 'inline' => true))))); 
echo $form->end();?>